function foo(this: { name: string }, info: { name: string }) {
  console.log(this, info.name);
}

type FooType = typeof foo;
// 1.获取FooType类型中this的类型
type FooThisType = ThisParameterType<FooType>;

// 2.OmitThisParameter: 抛出this的其他函数类型
type PureFooType = OmitThisParameter<FooType>;

// 3. ThisType: 用于绑定上下文的this
interface IState {
  name: string;
  age: number;
}
interface IStore {
  state: IState;
  eatting: () => void;
  running: () => void;
}

// 为store绑定为state的this
const store: IStore & ThisType<IState> = {
  state: {
    name: "zs",
    age: 12,
  },
  eatting: function (this: IState) {
    console.log(this.name);
  },
  running: function () {
    console.log(this.name, this.age);
  },
};

store.eatting.call(store.state);

export {};
